import 'package:flutter/cupertino.dart';

class OverlayManager {
  static final OverlayManager _instance = OverlayManager._internal();

  factory OverlayManager() => _instance;

  OverlayManager._internal();

  final List<OverlayEntry> _overlays = [];

  void addOverlay(OverlayEntry overlayEntry) {
    _overlays.add(overlayEntry);
  }

  void removeOverlay(OverlayEntry overlayEntry) {
    overlayEntry.remove();
    _overlays.remove(overlayEntry);
  }

  void removeAllOverlays() {
    for (var overlayEntry in _overlays) {
      overlayEntry.remove();
    }
    _overlays.clear();
  }
}
